package com.shujia.mr.output;

import com.shujia.mr.mapJoin.MapJoinDriver;
import com.shujia.mr.mapJoin.MapJoinMapper;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;
import java.net.URI;

public class OutputDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        Configuration conf = new Configuration();

        Job job = Job.getInstance(conf);
        job.setJarByClass(OutputDriver.class);
        job.setJobName("MapJoin");

        job.setMapperClass(OutputMapper.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);

        // 设置自定义输出类 要求为 Class<? extends OutputFormat> 子类
        job.setOutputFormatClass(MyOutPutFormat.class);


        // addInputPath该方式读取数据是按行读取，在MapJoin中不能通过该方式进行
        FileInputFormat.addInputPath(job,new Path("output/count"));
        FileOutputFormat.setOutputPath(job,new Path("output/output"));

        job.waitForCompletion(true);
    }
}
